package eazy;

public class removeDuplicates_26 {
    //slow每动一次代表有一个不重复的元素，fast负责遍历所有元素。
    public static void main(String[] args) {
        removeDuplicates_26 removeDuplicates_26 = new removeDuplicates_26();
        int[] s=new int[]{0,0,1,1,1,2,2,3,3,4};
        int i = removeDuplicates_26.removeDuplicates(s);
        System.out.println(i);
    }
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n == 0) {
            return 0;
        }
        int fast = 1, slow = 1;
        while (fast < n) {
            if (nums[fast] != nums[fast - 1]) {
                nums[slow]=nums[fast];
                ++slow;
            }
            ++fast;
        }
        return slow;
    }
}

